<template>
<div>
  <Form ref="form" :model="form" :rules="rules">
    <FormItem lable="类型名称" prop="name">
      <Input v-model="form.name" style="width: 350px" placeholder="请输入类型名称"></Input>
    </FormItem>
    <FormItem lable="备注">
      <Input v-model="form.rematkers" style="width: 350px" placeholder="请输入备注"></Input>
    </FormItem>
    <FormItem>
      <Button style="margin: 5px" type="primary" @click="add">提交</Button>
      <Button @click="quxiao">取消</Button>
    </FormItem>
  </Form>
</div>
</template>

<script>
export default {
  name: "addClassify",
  data(){
    return{
      form:{
        name:null,
        rematkers:null
      },
      rules:{
        name: [{required: true, message: '请输入类型名称'}],
      }
    }
  },
  methods:{
    add(){
      this.$refs['form'].validate(valid => {
        if (valid){
          this.http.post("/setClassify",this.qs.parse(this.form)).then(res=>{
            if (res.data){
              this.$Message.success('添加类型成功')
              this.$emit("hideDialog")
              this.$emit("after")
            }else {
              this.$Message.error('添加类型失败')
            }
          })
        }
      })
    },
    quxiao(){
      this.$emit("hideDialog")
    }
  }
}
</script>

<style scoped>

</style>
